package com.petplanet.shop.view.page

import android.widget.Toast
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button
import androidx.compose.material3.Card
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import com.petplanet.common.ui.layout.ColumnWithRecycleView
import com.petplanet.common.ui.widgets.SearchBar
import com.petplanet.shop.view.widgets.ShopHeaderBar

@Composable
internal fun ShopMainPage() {
    Column(
        modifier = Modifier.fillMaxSize(),
        horizontalAlignment = Alignment.CenterHorizontally,
        verticalArrangement = Arrangement.Top
    ) {
        ShopHeaderBar(
            leftContent = { /*TODO*/ },
            centerContent = { SearchBar(searchAction = {  }) },
            rightContent = { /*TODO*/ },
            centerWeight = 5f
        ) {
            val context = LocalContext.current
            ColumnWithRecycleView(
                modifier = Modifier
                    .border(2.dp, Color.Green),
                items = List(1000) {"item $it"},
                headerContent = {
                    Card(
                        modifier = Modifier
                            .fillMaxWidth()
                            .height(120.dp)
                    ) {
                        Text(text = "Header")
                    }
                },

            ) {
                Column(
                    modifier = Modifier.padding(8.dp)
                ) {
                    Button(onClick = {
                        Toast.makeText(context, "clicked $it", Toast.LENGTH_SHORT).show()
                    }) {
                        Text(text = it)
                    }
                    Box(
                        modifier = Modifier
                            .fillMaxWidth()
                            .height(2.dp)
                            .background(color = MaterialTheme.colorScheme.onSurface)
                    )
                }

            }
        }
    }

}